/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package x10.queues;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.Queue;
import x10.utilities.ChunkOfBytes;

/**
 *
 * @author Denny
 */
public class X10TransmitQueue {
    Queue<ChunkOfBytes> queue;

    public X10TransmitQueue(){
        queue = new LinkedList<ChunkOfBytes>();
    }

    public void put(ChunkOfBytes bytes){
        queue.add(bytes);
    }

    public ChunkOfBytes pop(){
        return queue.remove();
    }

    public boolean hasNext(){
        return !queue.isEmpty();
    }

    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        sb.append("Transmit Queue\n");

        Iterator<ChunkOfBytes> it = queue.iterator();
        while(it.hasNext()){
            ChunkOfBytes bytes = (ChunkOfBytes)it.next();
            sb.append(bytes.toString());
            sb.append("\n");
        }
        return sb.toString();
    }
}
